layui.define(['common','layer'],function(exports){
    var common=layui.common;
    var baseUrl=window.location.protocol+'//'+window.location.host
    common.include_js(baseUrl+'/statics/third-pkg/axios/axios.mini.js').then((axios)=>{
        layui.define( function (exports) {
            const instance = axios.create({
                baseURL: 'http://127.0.0.1:9000/',
                timeout: 10000,
            });
            var config = {
                headers: {
                    'Content-Type': 'application/json;charset=utf-8'
                }
            };
            var myajax = {
                post: function (url, data) {
                    return instance.post(url, data, config);
                },
                get: function (url) {
                    return instance.get(url,config);
                },
                delete:function (url){
                    return instance.delete(url,config);
                },
                setConfig: function (key, value) {
                    config[key] = value;
                }
            };
            exports('request', myajax);
        });

    }).catch((reason)=>{
        throw new Error('请求库加载失败')
    });
});